package com.hx;

import java.io.*;
import java.net.Socket;

/**
 * @author Huathy
 * @date 2021-10-11 23:40
 * @description
 */
public class ClientSocketDemo1 {
    public static void main(String[] args) {
        try {
            Socket socket = new Socket("127.0.0.1",8888);
            PrintWriter out = new PrintWriter(socket.getOutputStream(),true);
            //控制台输入流
            BufferedReader sin = new BufferedReader(new InputStreamReader(System.in));
            //拿到输入流
            BufferedReader in = new BufferedReader(new InputStreamReader(socket.getInputStream()));

            //获得控制台输入
            String readLine = sin.readLine();
            while (!"bye".equalsIgnoreCase(readLine)){
                out.println(readLine);
                System.out.println("Server:" + in.readLine());
                readLine = sin.readLine();
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
